package com.elinkway.infinitemovies.async;

import android.content.Context;

import com.elinkway.infinitemovies.bean.SubscriptionAlbum;
import com.elinkway.infinitemovies.http.api.MoviesHttpApi;
import com.elinkway.infinitemovies.http.parser.SubscriptionAlbumParser;
import com.elinkway.infinitemovies.utils.LogUtils;
import com.lvideo.http.bean.LVideoDataHull;

/**
 * Created by zhaopeipei on 2016/9/8.
 */
public class RequestSubscriptionAlbumTask extends MoviesHttpAsyncTask <SubscriptionAlbum> {

    private String mAid;

    private String mOffset;

    private String mLimit;

    private boolean mIsLoadMore;

    private RequestResultListener<SubscriptionAlbum> mListener;

    public RequestSubscriptionAlbumTask(Context context, String aid, String offset, String limit, boolean isLoadMore) {
        super(context);
        mAid = aid;
        mOffset = offset;
        mLimit = limit;
        mIsLoadMore = isLoadMore;
    }

    public void setOnListener(RequestResultListener<SubscriptionAlbum> listener) {
        mListener = listener;
    }


    @Override
    public void netNull() {
        super.netNull();
    }

    @Override
    public void netErr(int updateId, String errMsg) {
        super.netErr(updateId, errMsg);
    }

    @Override
    public void dataNull(int updateId, String errMsg) {
        super.dataNull(updateId, errMsg);
    }

    @Override
    public LVideoDataHull<SubscriptionAlbum> doInBackground() {
        LVideoDataHull<SubscriptionAlbum> ret = MoviesHttpApi.requestSubscriptionAlbum(
                new SubscriptionAlbumParser(), mAid, mOffset, mLimit);
        LogUtils.e("", "Enter PlayActivitySelfOwn Video Task");
        if (ret.getDataType() == LVideoDataHull.DataType.DATA_IS_INTEGRITY) {
            SubscriptionAlbum v = ret.getDataEntity();
            LogUtils.e("", "Enter PlayActivitySelfOwn Video Task INT");
        }
        return ret;
    }

    @Override
    public void onPostExecute(int updateId, SubscriptionAlbum result) {
        if(null != mListener){
            result.setLoadMore(mIsLoadMore);
            mListener.onRequestSuccess(updateId, result);
        }
    }

}
